package com.xuecheng.content.controller;

import com.xuecheng.content.dto.BindTeachplanMediaDto;
import com.xuecheng.content.dto.SaveTeachplanDto;
import com.xuecheng.content.dto.TeacherPlanDto;
import com.xuecheng.content.service.TeachPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName TeacherPlanController
 * @Description 课程计划管理相关的接口
 * @Author CG
 * @Date 2023/11/26 19:30
 **/
@Api(value = "课程计划编辑接口",tags = "课程计划编辑接口")
@RestController
public class TeacherPlanController {

    @Resource
    private TeachPlanService teachPlanService;

    @ApiOperation("查询课程计划属性结构")
    @ApiImplicitParam(value = "courseId",name = "课程Id",required = true,dataType = "Long",paramType = "path")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeacherPlanDto> getTreeNodes(@PathVariable("courseId") Long courseId){
        return teachPlanService.findTeacherPlanTree(courseId);
    }


    @ApiOperation("课程计划创建或修改")
    @PostMapping("/teachplan")
    public void saveTeachplan( @RequestBody SaveTeachplanDto teachplan){
        teachPlanService.saveTeachplan(teachplan);
    }


    @ApiOperation("删除课程计划接口")
    @DeleteMapping("/teachplan/{id}")
    public void deleteTeachplan(@PathVariable("id") Long id){
        teachPlanService.deleteTeachplan(id);
    }


    @ApiOperation(value = "课程计划和媒资信息绑定")
    @PostMapping("/teachplan/association/media")
    public void associationMedia(@RequestBody BindTeachplanMediaDto bindTeachplanMediaDto){
        teachPlanService.associationMedia(bindTeachplanMediaDto);
    }


}
